#include<cstdio>
#include<iostream>
#include<cmath>

using namespace std;

int R[17],G[17],B[17],r,g,b;
double cl(int r,int g,int b,int i){
    return sqrt((double)(r-R[i])*(r-R[i])+(double)(g-G[i])*(g-G[i])+(double)(b-B[i])*(b-B[i]));
}
int main(){
    for(int i=1;i<=16;i++){
        cin>>R[i]>>G[i]>>B[i];
    }
    while(scanf("%d%d%d",&r,&g,&b)==3&&r!=-1&&g!=-1&&b!=-1){
        int ans,flag=0,minn=0x3f3f3f;
        for(int i=1;i<=16;i++){
            ans=cl(r,g,b,i);
            if(ans<minn){
                minn=ans;
                flag=i;
            }
        }
        printf("(%d,%d,%d) maps to (%d,%d,%d)\n",r,g,b,R[flag],G[flag],B[flag]);
    }
    return 0;
}
